You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
504 B
14 lines
504 B
import { getPostForUser } from "#server/service/posts";
|
|
|
|
export default defineWrappedResponseHandler(async (event) => {
|
|
const user = await event.context.auth.requireUser();
|
|
const id = Number(event.context.params?.id);
|
|
if (!Number.isInteger(id)) {
|
|
throw createError({ statusCode: 400, statusMessage: "无效 id" });
|
|
}
|
|
const post = await getPostForUser(user.id, id);
|
|
if (!post) {
|
|
throw createError({ statusCode: 404, statusMessage: "未找到" });
|
|
}
|
|
return R.success({ post });
|
|
});
|
|
|